*Descriptive Statistics
graph box logLER, over(regimetype)
twoway (scatter logLER pol21 if initally==1, sort) (lowess logLER pol21 if initally==1) (scatter logLER pol21 if targally==1, sort) (lowess logLER pol21 if targally==1) (scatter logLER pol21 if joinally==1, sort) (lowess logLER pol21 if joinally==1) (lowess logLER pol21), ytitle(Log of LER) xtitle(Polity Score) title(Figure 3.Scatter Plot of Loss Exchange Ratio by Polity Score) legend(on) 

**RS Linear Model Replication**
*RS Model 4 from Table 2.2*
probit wl polini poltarg init concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4, robust
*RS Model 4 from Table 2.2 excluding cases where LER is missing*
probit wl polini poltarg init concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4, robust, if logLER!=.
*Regression Analysis using RS Model on RS cases (draws excluded)*
reg logLER polini poltarg init concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4, robust, if wl!=.

*Robustness check referenced in footnote 11
reg logLER polini poltarg init concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4, robust cluster (war), if wl!=.

*Regression Diagnostics referenced in footnote 12. Rerun the "Regression Analysis using RS Model on RS cases (draw excluded)*
*For Normality
predict RS4, resid
kdensity RS4, normal
pnorm RS4
qnorm RS4
swilk RS4
drop RS4
*Tests for Heteroskedasticty
rvfplot, yline(0)
estat imtest, white
*Tests for influential observations
scatter logLER pol21, mlabel(ccode)
generate outlier=1 if ccode==663 & war==65
replace outlier=1 if ccode==255 & war==60
replace outlier=1 if ccode==345 & war==60
replace outlier=2 if ccode==350 & war==91
replace outlier=2 if ccode==666 & war==73
replace outlier=2 if ccode==365 & war==40
replace outlier=0 if outlier==.
generate outlier2=1 if outlier==1
replace outlier2=1 if outlier==2
generate J65=1 if ccode==663 & war==65
generate G60=1 if ccode==255 & war==60
generate Y60=1 if ccode==345 & war==60
reg logLER polini poltarg init concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4, robust, if wl!=. & outlier !=1
reg logLER polini poltarg init concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4, robust, if wl!=. & outlier2 !=1
reg logLER polini poltarg init concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4, robust, if wl!=. & J65 !=1
reg logLER polini poltarg init concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4, robust, if wl!=. & G60 !=1
reg logLER polini poltarg init concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4, robust, if wl!=. & Y60 !=1
list war name ccode actor_na LER if outlier==1 | outlier==2

**ABD Ordered Probit**
*Model 3 from Table 1 in IS*
oprobit wdldownes pol21 initally targally pol21initally pol21targally concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4, robust cluster(war)
*ABD Model 3 from Table 1 in IS excluded cases where LER is missing
oprobit wdldownes pol21 initally targally pol21initally pol21targally concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4, robust cluster(war), if logLER!=.
*ABD Model 3 from Table 1 in IS using new data
reg logLER pol21 initally targally pol21initally pol21targally concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4, robust cluster(war)
*Regression Diagnostics referenced in footnote 14
*Normality Tests
predict D3, resid
kdensity D3, normal
pnorm D3
qnorm D3
swilk D3
drop D3
*Tests for Heteroskedasticty
reg logLER pol21 initally targally pol21initally pol21targally concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4, robust 
rvfplot, yline(0)
estat imtest, white
*Outlier Tests
reg logLER pol21 initally targally pol21initally pol21targally concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4, robust cluster(war), if outlier!=1
reg logLER pol21 initally targally pol21initally pol21targally concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4, robust cluster(war), if outlier2!=1
reg logLER pol21 initally targally pol21initally pol21targally concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4, robust cluster(war), if J65!=1
reg logLER pol21 initally targally pol21initally pol21targally concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4, robust cluster(war), if G60!=1
reg logLER pol21 initally targally pol21initally pol21targally concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4, robust cluster(war), if Y60!=1

**RS Curvilinear**
*RS Table 2 from IS Correspondence*
probit wldownes   pol21targally initally  pcini1old  pcini2old concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4 if wdldownes>1  | wdldownes<1, robust cluster (war),
*RS Table 2 from IS Correspondence excluding cases where ler data is missing
probit wldownes   pol21targally initally  pcini1old  pcini2old concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4 if (wdldownes>1  | wdldownes<1) & logLER!=., robust cluster (war)
*RS Table 2 from IS Correspondence with new data
reg logLER pol21targally initally  pcini1old  pcini2old concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4 if wdldownes>1  | wdldownes<1, robust cluster (war)
*F Tests on Democracy Variabls
test pol21targally
test pcini1old pcini2old
*Regression Diagnostics references in footnote 16
*Normality Tests
predict C9, resid
kdensity C9, normal
pnorm C9
qnorm C9
swilk C9
drop C9
*Tests for Heteroskedasticty
rvfplot, yline(0)
reg logLER pol21targally initally  pcini1old  pcini2old concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4 if wdldownes>1  | wdldownes<1, robust 
estat imtest, white

*Outlier Tests
reg logLER pol21targally initally  pcini1old  pcini2old concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4 if (wdldownes>1  | wdldownes<1) & outlier!=1, robust cluster (war) 
test pcini1old pcini2old
reg logLER pol21targally initally  pcini1old  pcini2old concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4 if (wdldownes>1  | wdldownes<1) & outlier2!=1 , robust cluster (war)
test pcini1old pcini2old
reg logLER pol21targally initally  pcini1old  pcini2old concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4 if (wdldownes>1  | wdldownes<1) & J65!=1, robust cluster (war)
test pcini1old pcini2old
reg logLER pol21targally initally  pcini1old  pcini2old concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4 if (wdldownes>1  | wdldownes<1) & G60!=1, robust cluster (war)
test pcini1old pcini2old
reg logLER pol21targally initally  pcini1old  pcini2old concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4 if (wdldownes>1  | wdldownes<1) & Y60!=1, robust cluster (war)
test pcini1old pcini2old

** Additional Regression Diagnostics**
reg logLER pol21 initally targally pol21initally pol21targally concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4, robust cluster(war)
reg logLER pol21 initally targally pol21initally pol21targally concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4, 
lvr2plot, mlabel(warname name)
reg logLER pol21 initally targally pol21initally pol21targally concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4,
predict d1, cooksd
clist warname name logLER d1 if d1>4/234

reg logLER pol21 initally targally pol21initally pol21targally concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4, vce(cluster war)
predict RES, residuals
reg RES pol21 initally targally pol21initally pol21targally concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4
reg RES pol21 pol21initally pol21targally qualrat 

reg logLER pol21 initally targally pol21initally pol21targally concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4
imtest, white
hettest
rvfplot, yline(0)

reg logLER pol21 initally targally pol21initally pol21targally concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4 [aw=1/pol21]
hettest
rvfplot, yline(0)

reg logLER pol21 initally targally pol21initally pol21targally concap capasst qualrat terrain straterr strat1 strat2 strat3 strat4 [aw=1/pol21], vce(cluster war)
rvfplot, yline(0)
